Database reference guide

HOME

Wildcard Operators

The LIKE operator is used to select records that satisfy a specific pattern by using wildcard characters, for example:

SELECT * FROM Customer WHERE Surname LIKE "SM*";

Will include all customers whose Surname begins SM, e.g. SMITH, SMYTH, SMALL etc.

Record Forename Surname Sex Age Town
0 HILDA SMITH F 35 BRISTOL
1 JOHN SMITH M 42 CARDIFF
4 ALISON SMYTH F 21 BRISTOL
5 DOUG SMALL M 35 CHESTER
Note:

Specifying LIKE "SMITH*" will include all variations of the SMITH surname. Another form of wildcard is the any charac­ter symbol '?', for example: s.

SELECT Count(*)

FROM Customer

WHERE Surname LIKE “SM?TH”;

In the example above, the third character can be any character. This will include all customers with surnames SMITH or SMYTH but not SMALL. The final form of wild card is the contains character %. If % is placed before the text of the data then all records that contain the text following the % will be included in the Domain. See following example:

Record Address
0 "FLAT 1A LOWER CHURCH ROAD"
1 "7 THE GREEN"
2 "23 WILLOW STREET"
3 "GROUND FLOOR FLAT THE MALTINGS"

Then the statement:

SELECT *

FROM Customer

WHERE Address LIKE “%FLAT”;

Will produce the following Domain:

Record Address
0 "FLAT 1A LOWER CHURCH ROAD"
3 "GROUND FLOOR FLAT THE MALTINGS"

  Online & Instructor-Led Courses | Training Videos | Webinar Recordings
© Alterian. All Rights Reserved. | Privacy Policy | Legal Notice